import * as SwipeTracker from './swipeTracker.js';
import {formatDateWithCFormatString} from '../misc/dateUtils.js';
import * as AuthPrompt from '../gdm/authPrompt.js';
+import {MprisSource} from './mpris.js';
+import {MediaMessage} from './messageList.js';
// The timeout before going back automatically to the lock screen (in seconds)
const IDLE_TIMEOUT = 2 * 60;
});
this.add_child(this._scrollView);
+ this._players = new Map();
+ this._mediaSource = new MprisSource();
+ this._mediaSource.connectObject(
+ 'player-added', (o, player) => this._addPlayer(player),
+ 'player-removed', (o, player) => this._removePlayer(player),
+ this);
+ this._mediaSource.players.forEach(player => {
+ this._addPlayer(player);
+ });
+
this._settings = new Gio.Settings({
schema_id: 'org.gnome.desktop.notifications',
});
let items = this._sources.entries();
for (let [source, obj] of items)
this._removeSource(source, obj);
+
+ for (const player of this._players.keys())
+ this._removePlayer(player);
}
_updateVisibility() {
this.emit('wake-up-screen');
}
+ _addPlayer(player) {
+ const message = new MediaMessage(player);
+ this._players.set(player, message);
+ this._notificationBox.insert_child_at_index(message, 0);
+ this._updateVisibility();
+ }
+
+ _removePlayer(player) {
+ const message = this._players.get(player);
+ this._players.delete(player);
+ message.destroy();
+ this._updateVisibility();
+ }
+
_sourceAdded(tray, source, initial) {
let obj = {
visible: source.policy.showInLockScreen,
x_expand: true,
});
this._showSource(source, obj, obj.sourceBox);
- this._notificationBox.add_child(obj.sourceBox);
+ this._notificationBox.insert_child_at_index(obj.sourceBox, this._players.size);
source.connectObject(
'notify::count', () => this._countChanged(source, obj),